# -*- coding: utf-8 -*-

import smtplib
from email.header import Header
from email.mime.text import MIMEText

MAIL = {
    "from": "willrise_cn@163.com",
    "pwd": "PTKBZOSPXNLMKRJF",
    "smtp": "smtp.163.com",
}
receiver_list = ["acqui_zhang@foxmail.com"]


def sendMail(remark):
    msg = MIMEText(
        "温馨提示！您的批处理任务“<span style='color:red;font-weight:bold;'>{}</span>”即将完成，请及时查看！".format(
            remark
        ),
        "plain",
        "utf-8",
    )
    msg["Subject"] = Header("ComfyUI 系统提示", "utf-8")  # 标题
    msg["From"] = MAIL["from"]  # 发件人
    msg["To"] = receiver_list[0]  # 收件人

    try:
        server = smtplib.SMTP(MAIL["smtp"])
        server.login(MAIL["from"], MAIL["pwd"])
        server.sendmail(MAIL["from"], receiver_list, msg.as_string())
        print("发送成功")
        server.quit()  # 关闭连接
    except Exception as e:
        print("发送邮件出错：", e)
